var g_gameDataManager = require("g_gameDataManager");
var MessageManager = require("MessageManager");
cc.Class({
    extends: cc.Component,

    properties: {
        inputID:cc.EditBox,
        inputPwd:cc.EditBox
    },

    // use this for initialization
    onLoad: function () {
        this.inputID.string = g_gameDataManager.getUserID();
        this.inputPwd.string = g_gameDataManager.getUserPassword();
        var cmdId = require("ProtoCmdID").Login;
        NotificationCenter.on(cmdId,this.loginResponse,this);
    },

    loginResponse:function(eventObj)
    {
        //console.log("loginResponse"+msg.cmdID);
        var msg = eventObj.msg;
        if(msg.errInfo.errorCode == 0)
        {
            //login error
        }
        else
        {
            //login success
            g_gameDataManager.setUserID(this.inputID.string);
            g_gameDataManager.setUserPassword(this.inputPwd.string);
            g_gameDataManager.msgTemp = msg;
            cc.director.loadScene('HomeScene');
        }
    },

    loginCallBack:function(event)
    {
        var inputID = parseInt(this.inputID.string);
        var passStr = this.inputPwd.string;
        MessageManager.login(inputID,passStr);
    },

    onDestroy:function()
    {
        var cmdId = require("ProtoCmdID").Login;
        NotificationCenter.off(cmdId, this.loginResponse, this);
    },

});
